<?php
class HTech_View_Helper_ArraySumByIndex extends Zend_View_Helper_Abstract
{
    public $view;

    public function arraySumByIndex($array,$index)
    {
        return array_sum(
            iterator_to_array(
                new RegexIterator(
                    new RecursiveIteratorIterator(
                        new RecursiveArrayIterator($array)
                    ), 
                    sprintf('/^%s$/D',$index), 
                    RegexIterator::MATCH, 
                    RegexIterator::USE_KEY
                ), 
                false
            )
        );
    }

    public function setView(Zend_View_Interface $view)
    {
        $this->view = $view;
    }
}
?>